package com.bosssoft.gateway.authorization.api.controller;

import com.bosssoft.gateway.authorization.api.Authorization;
import com.bosssoft.gateway.authorization.api.client.UserFeignClient;
import com.bosssoft.gateway.authorization.serve.service.AuthorizationService;
import com.bosssoft.gateway.authorization.serve.service.RenewTokenService;
import common.data.commonresponse.CommonResponse;
import common.util.CommonResponseUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @className: 删掉
 * @description: 解决什么问题：
 * 演示线程池的正确使用
 * 主要方法：
 * methodxx 使用 ThreadPoolExecutor创建线程进行任务操作
 * 注意事项：
 * 例如：该类需要从容器获取不可以new
 * @author: lanyukai
 * @date: 2024/6/18 23:13
 * @since 1.0
 **/
@Slf4j
@RestController
public class AuthorizetionController implements Authorization {
    @Resource
    private AuthorizationService authorizationService;
    /**
     * 用于认证失败 token续约
     */
    @Resource
    private RenewTokenService renewTokenService;
    @Autowired
    private UserFeignClient userFeignClient;

    @Override
    public Integer roleAuthorization(String token, String url) {
        log.info("roleAuthorization url={}, token={},", url, token);
        return authorizationService.roleAuthorization(token, url);

    }


    @Override
    public Boolean commonResource(String url) {
        log.info("roleAuthorization url={}", url);
        return authorizationService.commonResource(url);
    }

    @Override
    public String renewToken(String userId) {
        return renewTokenService.renewToken(userId);
    }

    @Override
    public CommonResponse<Object> createDynamicRoute() {
        log.info("-----------------");
        return userFeignClient.createDynamicRoute();
    }

}
